Repository navigation
fix(record-context): a related object's read that fails is a failure, not a refusal - #37550
objectstack-fleet[bot] wants to merge 4 commits into
Conversation
… not a refusal At the reads of a related object get_record_context judges (step 4a's exposure check and served definition, a published definition, the child list query), one helper tells a coded refusal from a failure: a refusal answers as before, a failure fails the call SERVICE_UNAVAILABLE (503) naming the pack and the root only, with the original on cause. The citation verifier reads the same classifier. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 03d08c1cf2185a12a867e1557c47ee21b6a2e4fc && git checkout 03d08c1cf2185a12a867e1557c47ee21b6a2e4fc
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 411646562566a1e12b4e0fc3de256192e8302719 bd03a37ed869418622699397ed127f0dccdceea6 && git checkout -B drift-repro 411646562566a1e12b4e0fc3de256192e8302719 && git merge --no-ff bd03a37ed869418622699397ed127f0dccdceea6
node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 32aba54 · 2026-11-26T13:12Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: PR #37550, card #37463. Read: the card and its six comments (os-dev report 7192952275, amendment 7192997436), the PR body, the net diff (7 files), and the head's check-runs (53 completed: 37 success, 16 skipped, 0 failed). Code outside the diff was read, not run. ① Derived judgments
M1 (must-fix) — at both MCP doors the outage is logged once, at S1 (should-fix) — the S2 (should-fix) — at the child list query, a refusal the door recognises without code-plus-status is now answered as an outage. On N1 (nit) — the changeset says all four reads were refused N2 (nit) — every uncoded throw is ② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…lt; door refusals at the list read stay A failure at a related object's read now answers INTERNAL_ERROR (500): SERVICE_UNAVAILABLE with a 5xx is a declared capability absence the doors log once per route at warn without the error. At the child list query the executor asks the /data door's own classifier (mapDataError), so a sandboxed hook's plain throw stays 400 HOOK_ABORTED and a status-less PERMISSION_DENIED stays 403; only a door fault fails. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…he door's refusals at the list read The doors' fault line prints an error's message and stack, never its cause, so the failure's stack ends with the original. The harness pins an error line per call per door with the outage in it, and the two refusals the /data door answers below 500 at the list read. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Fixes #37463
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
get_record_context(packages/services/service-record-context) reads each related object of a pack before it answers. At four of those reads, a throw that was not a refusal (an outage, a bug) was misanswered. At three of them it came back asPERMISSION_DENIED403, so the citation verifier (verifyRecordCitations) read it as a refusal and dropped every citation without a report:assertApiExposedfailure that is not a coded refusalINTERNAL_ERRORservedObjectDefinitionOf(child)throwingINTERNAL_ERRORpublishedOf, published-definition read throwingINTERNAL_ERROR/datadoor answers as a faultINTERNAL_ERROR, the original at the foot of the stackrefusedOrFaileddecides refusal vs failure at all four sites. At the three object-level sites it asksisCodedRefusal(inrecord-context-tools.ts, not on the package entry): the ADR-0112 line, a non-empty stringcodeplus a declared 4xx status (.status, then.statusCode). The verifier imports the same function in place of its private copy. At the child list query it asks the/datadoor's own classifier,mapDataErrorfrom@objectstack/types, which is new as a dependency of this package. Before this change the doors classified that read's throw themselves, so the executor asks them rather than keeping a second reader (seat ruling, REWORK 7193191377 S2).PERMISSION_DENIED403 within the naming bound; a disabled package'sOBJECT_PACKAGE_DISABLED(404, coded) is such a refusal. At the child list query, a throw the door answers below 500 is rethrown untouched, exactly as onmain. A sandboxedbeforeFindhook's plain throw stays400 HOOK_ABORTEDin the hook's words, and aPERMISSION_DENIEDwith no status stays the door'sPERMISSION_DENIED.INTERNAL_ERROR500, notSERVICE_UNAVAILABLE503. With a 5xx,SERVICE_UNAVAILABLEis onCAPABILITY_ABSENCE_CODES(packages/types/src/server-fault-log.ts), and the doors' fault line logs that code once per route per process, atwarn, without the error (record 7193179486, M1). WithINTERNAL_ERROR, each door logs the failure aterroron every call. The fault line prints an error's message and stack and never itscause(both the console sink andObjectLogger), so the failure's stack ends inCaused by:plus the original's stack. The original is also oncausefor an in-process host; the verifier hands it toonError. A stack never reaches the wire.{ code: 'INTERNAL_ERROR', status: 500 }with the messageInternal server error. The doors withhold a 5xx's own sentence, so the executor'sreadFailedsentence (en and zh-Hans; it names the pack and the root only) is read in-process only. Measured onmapDataError: the answer is500 INTERNAL_ERRORInternal server errorwhatevercauseholds. Tried with no cause, a plain error, a SQLite and a Postgres unique violation,SQLITE_BUSY, and a coded 403.verify-citations.ts: the docblock paragraph that this change made false is rewritten (claim amendment 7192997436).ADR-0160 (card item 3)
No ADR-0160 sentence fixes 403 for a failed read. The two sentences closest are about refusals only:
D3 "Object level" covers refusals by gates and says nothing on reads that fail. So no ADR text has to change for this PR; whether to add a sentence on failures stays with #37490.
Tests
record-context-tools.test.tshas a newdescribe, "a read of a related object that fails is a failure, not a refusal". It has one uncoded-throw case per site: 500, the exactreadFailedsentence, none of the outage's names, the original oncause, andCaused by:plus the original's stack in the failure's stack. It has a refusal control per object-level site (OBJECT_PACKAGE_DISABLED404 staysPERMISSION_DENIED403, unnamed) and for the child query (a coded refusal is rethrown unchanged). For S2: a sandboxed hook's plain throw (innerMessage) and a status-lessPERMISSION_DENIEDat the child query are rethrown untouched, while the same throws at an object-level read fail the call. A sandboxed body that crashed (a native error name) is a fault at the door, so it fails the call. A driver errno with no status, a coded 5xx, a status with no code, and a thrown string are failures too. The sentence follows the caller's locale.verify-citations.test.ts: an uncoded throw at the child's served-definition read drops the citation and is reported once throughonError(500, cause is the outage). A coded refusal there drops it and reports nothing. A control verifies the same citation.packages/runtime/src/mcp-record-context-tools-bridge.test.tsis the real-kernel harness, run on both doors. Outage: the related-list read ofrc_revisionthrows an uncoded error inengine.find. Asked twice, there are four[5xx] 500error lines (two doors times two calls), each carryingINTERNAL_ERRORandCaused by: Error: OUTAGE_TEXT(the thrown outage) in its stack, and no capability-absence warning. Both doors answer the same bytes,INTERNAL_ERROR500, with no object name and no outage text. S2, at the same read: a sandboxed hook's plain throw answersHOOK_ABORTED400 in the hook's words, and a status-lessPERMISSION_DENIEDanswersPERMISSION_DENIEDand never a 5xx. Each case has a control that reads once the spy is removed.Acceptance notes
main, so the citation verifier still reports a status-less one (PERMISSION_DENIEDwith no status, or a hook abort with no code) throughonError, as it did onmain. The verifier's rule (a stringcodeplus a declared 4xx) is unchanged.servedObjectDefinitionOf(...).catch(() => null)) still treats a throw as "not shown". The refusal is a real one, so a throw there only leaves out the object's name.INTERNAL_ERROR500, a bug included (N2 is accepted by the seat).Verification
Read first, by risk:
record-context-tools.ts:refusedOrFailed, the fourcatchsites that call it, and the child list query'smapDataErrorpredicate.record-context-tools.tsisCodedRefusal, andverify-citations.tsimporting it.packages/services/service-record-context/package.jsonandpnpm-lock.yaml: one workspace dependency,@objectstack/types.Two-minute check:
pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/record-context-tools.test.ts. Expect the newdescribeto pass, every case.Readings at head
bd03a37ed8(this container, shared box):Package suites, ablations, local gates, CI
pnpm --filter @objectstack/service-record-context test+typecheck: Test Files 4 passed (4), Tests 165 passed (165); tsc clean; check:test-typecheck OK.pnpm --filter @objectstack/runtime test(whole suite): Test Files 649 passed (649), Tests 12064 passed, 25 skipped. Lock VERDICT command-exit 0.pnpm install --frozen-lockfileafter the lock edit: exit 0, lockfile unchanged.scripts/ablation-replace.mjs: the failure's code reverted toSERVICE_UNAVAILABLE(blob a2fe90f00552 to 48864e37753e), rebuilt, marker present in dist. The harness outage case fails at the fault-line pin (a capability-absence warning was printed, and the expected empty list was not), 1 failed / 26 passed. The service suites go 12 failed / 129 passed.isCodedRefusal(blob a2fe90f00552 to 104602991144), rebuilt, marker in dist. Service 2 failed / 139 passed (both S2 cases); harness 2 failed / 25 passed (both S2 cases).git diff HEADempty; rebuilt; marker absent. 141/141 and 27/27 pass.dispatch-gates --ran: 83 derived, 82 run with exit 0, 1 NOT MEASURED. That one ischeck:dual-build-cjs-loads, which exited 3 with PREREQUISITE NOT MET because it needs every package's dist.check:type-check-debtfirst exited 3 on a lock queue-timeout; it was rerun with a slot and exited 0.bd03a37ed8: 69 check-runs, 60 success, 9 skipped, 0 failure. Every required context is green, the UI ones included.Generated by Claude Code